import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  // 附近店家
  {
    path: '/shop',
    name: 'shop',
    component: () => import('../views/shop.vue'),
  },
  // 地图
  // {
  //   path: '/shop/map',
  //   name: '/shop/map',
  //   component: () => import('../views/map.vue'),
  // },
  // 宠物保险
  {
    path: '/insurance',
    name: 'Insurance',
    component: () => import('../views/Insurance.vue'),
  },
  // 宠物圈详情页
  {
    path: '/text/details',
    name: '/text/details',
    component: () => import('../views/DynamicDetail.vue'),
  },
  //百科搜索框
  {
    path: '/adoptm/adoptmesssearch',
    name: 'adoptmesssearch',
    component: () => import('../views/adoptmessSearch.vue'),
  },
  //百科详情页

  {
    path: '/a/details',
    name: 'adoptmessdetail',
    component: () => import('../views/adoptmessDetail.vue'),
  },
  {
    path: '/mao',
    name: 'mao',
    component: () => import('../views/mao.vue'),
  },
  // 注册
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/Register.vue'),
  },
  // 登录
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/',
    redirect: '/home/index',
  },
  // 首页
  {
    path: '/home',
    name: 'home',
    redirect: '/home/index',
    component: HomeView,
    children: [
      {
        path: 'index',
        name: '/home/index',
        component: () => import('../views/Index.vue'),
      },
      {
        path: 'me',
        name: '/home/me',
        component: () => import('../views/Me.vue'),

      },
      {
        path: 'text',
        name: 'text',
        component: () => import('../views/Dynamic.vue'),
        meta: {  //自定义meta属性
          keepAlive: true  // 该属性为true，表示该组件需要保活
        },
      },
      {
        path: 'adoptm',
        name: 'adoptm',
        redirect: '/home/adoptm/mao',
        component: () => import('../views/AdoptMessage.vue'),
        meta: {  //自定义meta属性
          keepAlive: true  // 该属性为true，表示该组件需要保活
        },
        children: [
          {
            path: 'mao',
            name: 'mao',
            meta: { title: "三级标题1-2-4", hidden: false },
            component: () => import('@/views/mao.vue'),
            meta: {  //自定义meta属性
              keepAlive: true  // 该属性为true，表示该组件需要保活
            },
          },
          {
            path: 'gou',
            name: 'gou',
            meta: { title: "三级标题1-2-4", hidden: false },
            component: () => import('@/views/gou.vue'),
            meta: {  //自定义meta属性
              keepAlive: true  // 该属性为true，表示该组件需要保活
            },
          },
        ]
      },
    ],
  },
  // 视频
  {
    path: '/video/details',
    name: 'video',
    component: () => import('../views/video.vue'),
  },
  // 个人资料
  {
    path: '/person',
    name: 'person',
    component: () => import('../views/person.vue'),
  },
  // 我的宠物
  {
    path: '/myadopt',
    name: 'myadopt',
    component: () => import('../views/myadopt.vue'),
  },
  // 设置
  {
    path: '/shezhi',
    name: 'shezhi',
    component: () => import('../views/Shezhi.vue'),
  },
  // 我的收藏
  {
    path: '/mycol',
    name: 'mycollection',
    component: () => import('../views/myCollection.vue'),
  },

  // 领养宠物列表
  {
    path: '/adopt',
    name: 'adopt',
    component: () => import('../views/adopt.vue'),
    meta: {  //自定义meta属性
      keepAlive: true  // 该属性为true，表示该组件需要保活
    },
  },
  // 领养宠物详情页
  {
    path: '/adopt/details',
    name: 'adopt',
    props: true,
    component: () => import('../views/adoptDetails.vue'),
  },
  // 领养宠物搜索
  {
    path: '/adopt/search',
    name: '/adopt/search',
    props: true,
    component: () => import('../views/adoptSearch.vue'),
  },
  // 领养协议
  {
    path: '/xieyi',
    name: 'xieyi',
    component: () => import('../views/XieYi.vue'),
  },
  // {
  //   path: '/text',
  //   name: 'text',
  //   component: () => import('../views/Dynamic.vue'),
  //   children: [
  //     {
  //       path: 'search',
  //       name: '/text/search',
  //       component: () => import('../views/search.vue'),
  //     }, {
  //       path: 'cwxq',
  //       name: '/text/details',
  //       component: () => import('../views/cwxq.vue'),
  //     },
  //   ],
  // },

  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router